# @Time  :2021/5/27 22:03
# @Author: Houtaroy
from typing import List
from copy import deepcopy


class TreeNode:
    """
    树形结构节点基础类
    """
    parent_id: int
    children: list


class TreeUtil:
    @staticmethod
    def expand(nodes: List[TreeNode]) -> list:
        """
        树形结构展开
        :param nodes: 树形结构数组
        :return: 展开的数组, 只有一级
        """
        result = []
        for node in nodes:
            item = deepcopy(node)
            result.append(item)
            if node.children is not None and len(node.children) > 0:
                result.extend(TreeUtil.expand(node.children))
        return list(set(result))
